import React, { Component } from 'react'
import Cate from './Cate'
import Cate2 from './Cate2'
import Header from './Header'


import { Route, withRouter, Switch, Redirect } from 'react-router-dom'

// 样式组件
import {
  CateContainer
} from './style'

@withRouter
class index extends Component {
  render() {
    let prePath = this.props.match.path
    return (
      <CateContainer>
        <Header />
        {/* 子组件 子组件匹配的前提  父组件先匹配成功 */}
        <Switch>
          <Route path={`${prePath}cate`} component={Cate} />
          <Route path={`${prePath}cookbook`} component={Cate2} />
          {/* 重定向完成 */}
          <Redirect from="/" to="/cate" />
        </Switch>
      </CateContainer>
    )
  }
}

export default index